﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WCSY.BLL;
using WCSY.MODEL;
using System.Data;

public partial class UserManagement_MainRoleLeft : System.Web.UI.Page
{
    Mg_roleManager roleM = new Mg_roleManager();
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack){
            
            initTree();
        
        }
    }

    //查询父角色
    private void initTree() {
        roleTreeView.Nodes.Clear();
        DataTable roleList = roleM.GetAllList().Tables[0];
        foreach(DataRow role in roleList.Rows){
            TreeNode root = new TreeNode();
            root.Text = role["roleName"].ToString();
            root.Value = role["id"].ToString();
           // root.PopulateOnDemand = false;
            //root.NavigateUrl = "MainRoleRight.aspx?roleId="+root.Value;
            root.Target = "Right";
            root.ImageUrl = "~/image/user.gif";
            this.roleTreeView.Nodes.Add(root);

        } 
    
    }

    //查询子角色
    private void childNodes(TreeNode child) {

        string sql = "select * from mg_role ";
    
    
    }
    //节点选中事件
    protected void roleTreeView_SelectedNodeChanged(object sender, EventArgs e)
    {
        //Response.Write("<script>alert('1234');</script>");
       // TreeNode tnCurrent = roleTreeView.SelectedNode;
        this.nodesvalue.Value = this.roleTreeView.SelectedNode.Value;
        //Response.Write("<script>alert('"+nodesvalue.Value+"');</script>");
        //Response.Write("<script>window.open('MainRoleUser.aspx?roleId='+'"+this.nodesvalue.Value+"','User','');</script>");
        Response.Write("<script>window.parent.User.location.href = 'MainRoleUser.aspx?roleId='+'" + this.nodesvalue.Value + "';</script>");
        //Response.Write("") = "MainRoleRight.aspx?roleId=" + nodesvalue.Value;
        //Response.Write("<script>window.open('MainRoleRight.aspx?roleId='+'" + this.nodesvalue.Value + "','Right','');</script>");
        Response.Write("<script>window.parent.Right.location = 'MainRoleRight.aspx?roleId='+'" + this.nodesvalue.Value + "';</script>");
        //Response.Write("<script>alert('1234');</script>");
        //tnCurrent.Selected = false;
        //roleTreeView.SelectedNode.Selected = false;
        //roleTreeView.Nodes.Clear();
        //initTree();
       
        //roleTreeView.SelectedNode.Selected = true;
        
        }

   
}
